<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>收货地址管理</title>
    <script type="text/javascript" src="__PUBLIC__/Js/home/jquery-1.11.3.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Js/layer/layer.js"></script>
    <script>
        //要写在user_common.js调用之前     因tp框架中定义的常量，在外部调用的js中不能被解析
        var tp_defined = {'url': '__URL__','self':'__SELF__'};
    </script>
    <script type="text/javascript" src="__PUBLIC__/Js/home/user_common.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/home/user_common.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/home/user_main_left.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/home/myAddress.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/home/addAddress.css">
    <script>
        $(function(){
            //调出、隐藏添加地址
            $('.member_adress-addtop').click(function () {
                var addAddress = $('.shop_adress-add');
                var css = addAddress.css('display');
                if (css == 'none') {
                    addAddress.css('display', 'block');
                } else {
                    addAddress.css('display', 'none');
                }
            });
            //保存地址按钮事件
            $(".save").click(function () {
                var data=check();
                if(data==false){
                    return;     //结果不正确，则不提交
                }
                //传递数据，并写入数据库中
                //加载层，样式2
                layer.load(1);
                $.post(
                        '__URL__/myAddress',
                        data,
                        function (data) {
                            layer.closeAll('loading');  //关闭加载层
                            if (data['status'] == 1) {
                                layer.msg(data['content'],{time:1000});
                                $('.shop_adress-add').css('display', 'none');
                                window.location.href = '__SELF__';
                            }else{
                                layer.alert(data['content']);
                            }
                        }
                );
            });
        });
    </script>
</head>
<body>
<include file='Common/header'/>
<!--中间-->
<div class="cort">
    <!--内容-->
    <div class="cmain mb_back">
        <div class="zbk_top spalid">
            <div class="zbk_top spalid">
                <div class="zbk_top spalid">
                    <span>您当前的位置：</span>
                    <span><a href="__MODULE__/Index/index" target="_top">Darry Ring</a></span>
                    <span><em>&gt;</em></span>
                    <span><a href="__MODULE__/User/index" target="_top">我的DR</a></span>
                    <span><em>&gt;</em></span>
                    <span>收货地址</span>
                </div>
            </div>
        </div>
        <!--中间内容-->
        <div class="member_cort">
            <!--引入左导航栏-->
            <include file="Common/user_main_left"/>
            <!--右边的主要内容-->
            <div class="member_cort-right fr">
                <!--收货地址-->
                <div class="member_adress">
                    <div class="myorder-xq-news_top">
                        <p>收货地址</p>
                        <a href="javascript:setDefaultAddress();" id="setDefaultAddress">设置默认地址</a>
                    </div>
                    <!--收货地址选择-->
                    <table class="member_adress-top" border="0" cellpadding="0" cellspacing="0">
                        <tr class="member_adress-trfirst">
                            <td class="member_adress-td0"></td>
                            <td class="member_adress-td1">收件人姓名</td>
                            <td class="member_adress-td2">详细地址</td>
                            <td class="member_adress-td3">联系方式</td>
                            <td class="member_adress-td4">邮政编码</td>
                            <td class="member_adress-td5">操作</td>
                        </tr>
                        <foreach name="address_data" item="v">
                            <tr class="member_adress-trsec-{$v['id']}">
                                <td>
                                    <neq name="v['status']" value="1">
                                        <input value="{$v['id']}" name="adress" type="radio">
                                        <else/>默认<br/>地址
                                    </neq>
                                </td>
                                <td>{$v['name']}</td>
                                <td>{$v['province']}{$v['city']}{$v['district']}{$v['street']}</td>
                                <td>{$v['mobile']}</td>
                                <td>{$v['postcode']}</td>
                                <td>
                                    <!--<a href="javascript:showAddress({$v['id']});">修改</a>
                                    <i>&nbsp;&nbsp;|&nbsp;&nbsp;</i>-->
                                    <a href="javascript:deleteAddress({$v['id']});">删除</a>
                                </td>
                            </tr>
                        </foreach>
                    </table>
                    <!--收货地址选择end-->
                    <!--新加地址按钮-->
                    <div class="member_adress-addtop">
                        <span>添加新地址</span> <i></i>
                    </div>
                    <!--引入添加地址-->
                    <div class="shop_adress-add" style="display: none">
                        <div class="shop_adress-Toadd" id="addresses" style="">
                            <label><em>*</em>地&nbsp;&nbsp;区：</label>
                            <select id="province">
                                <option value="-1">请选择省份</option>
                            </select>
                            <span>市：</span>
                            <select id="city">
                                <option value="-1">请选择城市</option>
                            </select>
                            <span>县：</span>
                            <select id="district">
                                <option value="-1">请选择区县</option>
                            </select>

                            <span id="addid">
                                <i class="writer_wrong"></i>
                                <em class="writer_word" id="addwrong"></em>
                            </span>
                        </div>
                        <!--详细地址-->
                        <div class="shop_adress-Toadd" id="detailadd">
                            <label class="adress-Toadd_label"><em>*</em>详细地址：</label><textarea maxlength="30" id="street"></textarea>
                            <span id="streeid">
                                <i class="writer_wrong"></i>
                                <em class="writer_word" id="strwrong"></em>
                            </span>
                        </div>
                        <!--收货人-->
                        <div class="shop_adress-Toadd" id="pname">
                            <label><em>*</em>收货人：</label><input value="" maxlength="10" id="addressName" class="true_name" type="text">
                            <span id="shrid">
                                <i class="writer_wrong"></i>
                                <em class="writer_word" id="shrwrong"></em>
                            </span>
                        </div>
                        <!--邮编-->
                        <div class="shop_adress-Toadd" id="post">
                            <label><em>*</em>邮政编码：</label><input value="" maxlength="6" id="postcode" class="true_number" type="text">
                            <span id="postid">
                                <i class="writer_wrong"></i>
                                <em class="writer_word" id="postwrong"></em>
                            </span>
                        </div>
                        <!--手机号-->
                        <div class="shop_adress-Toadd" id="lx" style="">
                            <label><em>*</em>手机号码：</label><input value="" maxlength="11" id="mobile" type="text">
                                <span id="telid">
                                    <i class="writer_wrong"></i>
                                    <em class="writer_word" id="telwrong"></em>
                                </span>
                        </div>
                        <div class="shop_adress-sp">
                            <input id="cbDefaultAddress" type="checkbox">
                            <label class="add_adress-splabel" for="cbDefaultAddress">设为默认地址</label>
                        </div>
                        <div class="shop_adress-save">
                            <div class="bt1"><span class="save">保存收货人信息</span></div>
                        </div>
                    </div>
                </div>
                <!--收货地址end-->
            </div>
            <!--右边的主要内容end-->
        </div>
        <!--中间内容end-->
    </div>
    <!--内容end-->
</div>
<!--中间end-->
<include file='Common/footer'/>
